/******************************************************************************/
/*  POB-Technology 2005                                                       */
/*                                                                            */
/* File : POBLCD128E3.c                                                       */
/*                                                                            */
/* An example to grab frame from the camera and draw this frame on the LCD    */
/*  screen.                                                                   */
/*                                                                            */
/******************************************************************************/

#include <pob-eye.h> /* pob-eye include */


int main (void)
{
	Int16 i=0,j=0,k=0,i_Cam=0,i_LCD=0;

	UInt8 LCD_Buffer [LCD_WIDTH*LCD_HEIGHT*BYTES]; /* LCD buffer, 128*64 pixel, 1 byte per pixel */

	GraphicBuffer LCD_Screen; /* graphic buffer */
	
	RGBFrame FrameFromCam;  /* frame of camera */

	InitPOBEYE(); /* init POB-EYE module */

	InitLCD(); /* init the LCD screen */


	/* init the graphic buffer : 128 per 64, 1 bytes per pixel and LCD_Buffer */
	InitGraphicBuffer(&LCD_Screen,LCD_WIDTH,LCD_HEIGHT,EIGHT_BITS,LCD_Buffer);

	/* clear the graphic buffer */
	ClearGraphicBuffer(&LCD_Screen);
	
	/* get the pointer of the red,green and blue video buffer */
	GetPointerOnRGBFrame(&FrameFromCam);

	/* main loop program */
	while (1)
	{
		/* grab the RGB components */
		GrabRGBFrame();
		
		/* binary the RGB buffer */
		BinaryRGBFrame(&FrameFromCam);

		/* put the pixel from the red component witch is binary, to the lcd buffer */
		for (k=0,i=63 ; i ; i--)
		{
			for (j=0;j<120;j++,k++)
			{
					LCD_Screen.buffer[k] = FrameFromCam.red[i+(j*88)];
			}
			k+=8;
		}

		/* draw the buffer on the screen */
		DrawLCD(&LCD_Screen);
	}

	return 0;
}
